package com.atguigu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.*;
import org.redisson.client.codec.Codec;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyRedissonConfig {
        @Bean(destroyMethod="shutdown")
        public RedissonClient redisson() throws IOException {
            //1.new 一个配置
          Config config=new Config();
          config.useSingleServer().setAddress("redis://192.168.56.10:6379");
          //2.根据config创建一个实例
           RedissonClient redissonClient=Redisson.create(config);
           return redissonClient;
        }

}
